﻿@model IEnumerable<ScrumProject.Models.Task>

@{
    ViewBag.Title = "Index";
}

<h2>Tasks</h2> 
<h5>Story name: @ViewBag.storyName</h5>
<p>
@{
    ScrumProject.Models.StoryRepository sr = new ScrumProject.Models.StoryRepository();
    ScrumProject.Models.Story story = sr.GetStory(ViewBag.storyId);

    if (!story.Status.Trim().Equals((string)"finished"))
    {
        @Html.ActionLink("Create New", "Create", new { storyId = ViewBag.storyId });
    }
}
</p>
<table class="table table-condensed">
    <tr>
        <th style="width: 500px;">
            Description
        </th>
        <th style="width: 20%">
            User
        </th>
        @*<th>
            Completed
        </th>*@
        <th style="width: 15%">
            Work Remaining
        </th>
        <th>
            Actions
        </th>
    </tr>

@foreach (var item in Model) {

    ScrumProject.Models.UserRepository uR = new ScrumProject.Models.UserRepository();
    string username = uR.GetUsername((int)item.UserId);
    
    <tr>
        <td style="display: table-cell;"><span style="display: block; "><center>@Html.DisplayFor(modelItem => item.Description)</center></span></td>
        <td>
        @if (item.UserId == -1) { 
            <center><label>Not selected</label></center>
        }
        <center>@Html.DisplayFor(modelItem => username)</center></td>

        @*<td><center>
            @if (item.Status.Equals(4) || item.Status.Equals(2) || item.Status.Equals(0))
            {
                <label style="color:#C4BBBE">Pending</label>
            }
            @if (item.Status.Equals(1))
            {
                <label style="color:#EDA137">Assigned</label>
            }
            @if (item.Status.Equals(3))
            {
                <label style="color:#65C429">Completed</label>
            }              
            //@Html.DisplayFor(modelItem => item.Status)
        </center></td>*@
        
        @*<td><center>@Html.DisplayFor(modelItem => item.Status)</center></td>*@
        <td style="width: 15%;"><center>@Html.DisplayFor(modelItem => item.WorkRemaining)</center></td>
        <td style="width: 15%;">
        @if (item.Status.Equals(4) || item.Status.Equals(2) || item.Status.Equals(0))
        {
            <center>
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Id }) 
            </center>
        }
           
        </td>
    </tr>
}

</table>
</center>
<div>
    @Html.ActionLink("Back", "SprintBacklog", "MyProjects", new { projectId = ViewBag.projectId }, null)
</div>

